#include <iostream>
#include <string>
#include <gtest/gtest.h>
#include "../mqserver/queue.hpp"
using namespace std;
rbmq::MsgQueueManager::ptr queue;
class QueueTest : public testing::Environment {
public :
    virtual void SetUp() override {
        queue = make_shared<rbmq::MsgQueueManager>("./data/meta.db");
    }
    virtual void TearDown() override {
        // queue->clear();
    }
private :
};

TEST(queue_test, insert_test) {

    unordered_map<string, string> args = { { "key1", "val1"}, {"key2", "val2" }, {"key3", "val3"}};
    queue->declareQueue("queue1", true, false, false, args);
    queue->declareQueue("queue2", true, false, false, args);
    queue->declareQueue("queue3", true, false, false, args);
    queue->declareQueue("queue4", true, false, false, args);
    ASSERT_EQ(queue->size(), 4);
}

TEST(queue_test, delete_test) {
    queue->deleteQueue("queue3");
    ASSERT_EQ(queue->size(), 3);
    ASSERT_EQ(queue->selectQueue("queue3").get(), nullptr);
}

// TEST(queue_test, delete_test) {
//     queue->deleteQueue("queue3");
//     ASSERT_EQ(queue->size(), 3);
//     ASSERT_EQ(queue->exists("queue3"), false);
//     ASSERT_EQ(queue->selectQueue("queue3").get(), nullptr);
// }

// TEST(queue_test, select_test) {
//     ASSERT_EQ(queue->selectQueue("queue1")->_auto_delete, false);
//     ASSERT_EQ(queue->selectQueue("queue2")->_auto_delete, false);
//     ASSERT_EQ(queue->selectQueue("queue3")->_auto_delete, false);
//     ASSERT_EQ(queue->selectQueue("queue4")->_auto_delete, false);
// }


int main(int argc, char* args[]) {
    testing::InitGoogleTest(&argc, args);
    testing::AddGlobalTestEnvironment(new QueueTest());
    RUN_ALL_TESTS();
    return 0;
}